Piping articles to Usenet how-to
This script was posted to comp.misc by RS Wood. Introduction In an effort to make sure others can help send articles to comp.misc, here's how I do it. If this is useful to you, send us some stuff to chat about! Usage My easy solution for scanning the news for interesting articles and sending them easily to comp.misc involves three bits: newsbeuter as console-based RSS reader, postnews.py (a python script that reads a text file and posts it to a news server including user name and password), and a little bash script that glues the two together. This little bash script accepts the standard input (which would be the article contents coming from newsbeuter), asks a few questions, puts it all together into a text file and sends that to postnews.py. Pretty simple stuff. Better BASH scripters than me will probably find dozens of ways to improve my work (I'd be interested in knowing them, actually - a learning experience). But this works pretty well. It allows me - while drinking my coffee - to scan the news, and pipe anything I find relevant to comp.misc. Fortunately, newsbeuter does a good job of organizing all the links down at the bottom of the post, which keeps the summaries readable. Badda boom, badda bing. If this is interesting, give it a try and help keep the conversation (and the coffee) flowing! Prerequisites Get newsbeuter for your *nix OS via the usual methods (or see http://newsbeuter.org). It's my favorite RSS reader, because it's for the console, and you can pipe any article you see by pressing | either in the article list or while reading the RSS article summary. I know it's available for Debian, openSUSE, and FreeBSD at a minimum. Get postnews.py at http://sourceforge.net/projects/postnews/It's a <10KB python script. #! /usr/local/bin/bash TEMPTEXT='/tmp/slashtemptext' TEMPHEADERS='/tmp/slashtempheaders' TEMPARTICLE='/tmp/slashtemparticle' DEPT='' SUBJ='' XPOST='' GROOP='' POSTIT= echo "" for i in $TEMPTEXT $TEMPHEADERS $TEMPARTICLE do echo "Nuking $i" if [ -e $i ]; then rm $i; fi done while read line; do echo "$line" >> $TEMPTEXT done echo "From: Whiny Troll " > $TEMPHEADERS echo "Content-Type: text/plain; charset=UTF-8" >> $TEMPHEADERS echo "" echo "This is a Slashdot/Pipedot Post. Enter Subject line:" read SUBJ < /dev/tty echo "" echo "Send to comp.misc or misc.news.internet.discuss?" echo "C comp.misc M m.n.i.d." read SENDTO < /dev/tty case $SENDTO in cC) GROOP='comp.misc' ;; mM) GROOP='misc.news.internet.discuss' ;; esac echo "" echo "Crosspost? Type one additional group or ENTER for none." echo "Follow-up will also be set: eg. misc.rabid.bunnies,comp.obnoxious.troll" read XPOST < /dev/tty if [ "$XPOST" != "" ]; then SUBJ="CM ${SUBJ}" GROOP="$GROOP,$XPOST" echo "Subject: $SUBJ" >> $TEMPHEADERS echo "Followup-To: $XPOST" >> $TEMPHEADERS else echo "Subject: $SUBJ" >> $TEMPHEADERS fi echo "Newsgroups: $GROOP" >> $TEMPHEADERS echo "" echo "From which dept? (eg. Happy go Lucky). I'll add the quotes." read DEPT < /dev/tty echo "" >> $TEMPHEADERS echo "From the «$DEPT» department:" >> $TEMPHEADERS cat $TEMPHEADERS $TEMPTEXT > $TEMPARTICLE echo "----" head -20 $TEMPARTICLE echo "Post it? (only 'y' will post)" read POSTIT < /dev/tty if [ "$POSTIT" = "y" ]; then exec postnews --user MYUSERNAME --pass MYPASSWORD -f $TEMPARTICLE MYNEWSSERVER else echo "Not posted." fi